<template>
  <div>
    <el-form ref="form" :model="form" :rules="rules" label-width="120px" class="dataForm">
      <el-row>
        <el-col :span="12">
          <el-form-item :label="$t('投资周期')" prop="investmentCycle">
            <el-input v-model="form.subscribeScale" :placeholder="$t('投资周期')" :maxlength="100" show-word-limit />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('投资方式')" prop="investmentMethod">
            <el-input v-model="form.investmentMethod" :placeholder="$t('投资方式')" :maxlength="100" show-word-limit />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('授权总额度') + $t('金额单位')" prop="totalAmountAuthorization">
            <Money v-model="form.totalAmountAuthorization" unit="W" :placeholder="$t('授权总额度')" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('预计收益') + '(%)'" prop="expectedEarnings">
            <Money v-model="form.expectedEarnings" unit="W" :placeholder="$t('预计收益')" />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item :label="$t('债务人收益状况')" prop="debtorIncome">
            <el-input v-model="form.debtorIncome" type="textarea" :placeholder="$t('债务人收益状况')" :maxlength="2000" show-word-limit />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item :label="$t('债务人债务状况')" prop="debtorDebtStatus">
            <el-input v-model="form.debtorDebtStatus" type="textarea" :placeholder="$t('债务人债务状况')" :maxlength="2000" show-word-limit />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item :label="$t('备注')" prop="remark">
            <el-input v-model="form.remark" type="textarea" :placeholder="$t('备注')" :maxlength="2000" show-word-limit />
          </el-form-item>
        </el-col>
      </el-row>
      <div class="area-header">
        <span class="area-header-title">{{ $t('债券信息') }}</span>
      </div>
      <dealBaseBondForm
        v-if="form.dealWfStorageBond !== undefined && form.dealWfStorageBond !== null"
        ref="dealBaseBondForm"
        :bond-form="form.dealWfStorageBond"
      />
    </el-form>
  </div>
</template>

<script>
import { getDealBaseBondByDealId } from '@/api/wfBondBase/dealWfBondBase.js'
import dealBaseBondForm from '@/views/deal/base/bond/dealBaseBondForm'
export default {
  name: 'BondInvestmentPlanForm',
  components: {
    dealBaseBondForm
  },
  data() {
    return {
      form: {
        subscribeScale: '24个月',
        investmentMethod: '债券投资',
        totalAmountAuthorization: 1000,
        expectedEarnings: '4%',
        debtorIncome: '债务人收益状况',
        debtorDebtStatus: '债务人债务状况',
        remark: undefined,
        dealWfStorageBond: {}
      },
      rules: {
        investmentCycle: [{ required: true, message: this.$t('必填信息'), trigger: 'blur' }],
        investmentMethod: [{ required: true, message: this.$t('必填信息'), trigger: 'blur' }]
      }
    }
  },
  mounted() {
    this.$bus.$emit('async_done')
  },
  methods: {
    init(data) {
      console.log(data)
      if (data && data.id !== undefined && data.id !== null) {
        console.log('加载表单数据')
      } else {
        getDealBaseBondByDealId(this.$route.query.id).then(res => {
          this.form.dealWfStorageBond = res.data
          try {
            var temp = this.form.dealWfStorageBond.secondaryBondCategory
          } catch (e) {
            console.log(e)
          }
          this.$nextTick(() => {
            this.form.dealWfStorageBond.secondaryBondCategory = temp
          })
        })
      }
    }
  }
}
</script>

<style scoped>

</style>
